﻿<html xmlns:th="http://www.thymeleaf.org">
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>菜单列表</title>
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <div th:include="layout/resources :: resources"></div>
</head>
<body>
<div class="container-fluid">
    <div id="toolbar">
        <button class="btn btn-default" onclick="add();">添加</button>
    </div>
    <table></table>
</div>

</body>
<script>
    $("table").framework().bootstrapTable({
        url: "/menu/getListByPage",
        columns: [{
            field: '',
            title: '序号',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                return index + 1;
            }
        }, {
            field: 'id',
            title: '操作',
            align: 'center',
            valign: 'middle',
            formatter: function (value, row, index) {
                return '<a href="javascript:deleteOne(' + value + ');">删除</a>';
            }
        }, {
            field: 'text',
            title: '菜单名称',
            align: 'center',
            valign: 'middle'
        }, {
            field: 'level',
            title: 'Level',
            align: 'center',
            valign: 'middle'
        }, {
            field: 'icon',
            title: 'Icon',
            align: 'center',
            valign: 'middle'
        }, {
            field: 'parentId',
            title: '父级节点',
            align: 'center',
            valign: 'middle'
        }, {
            field: 'url',
            title: '地址',
            align: 'center',
            valign: 'middle'
        }, {
            field: 'createTime',
            title: '创建时间',
            align: 'center',
            valign: 'middle'
        }]
    });

    function refresh() {
        $('table').bootstrapTable('refresh');
    }

    function add() {
        framework.openWindow("/menu/toAdd", "50%", "50%", "添加菜单");
    }

    function deleteOne(id) {
        $.ajax({
            method: "delete",
            url: createUrl("/menu/delete/" + id),
            success: function (result) {
                if (result.errorCode == 0) {
                    framework.successMsg("删除成功");
                } else {
                    framework.errorMsg("删除失败");
                }
            }
        })
    }
</script>
</html>
